from time import sleep
from selenium import webdriver
# from selenium.webdriver import ActionChains

driver = webdriver.Chrome()
driver.maximize_window()
driver.get("http://tpshop-test.itheima.net/")

# bd = driver.find_element_by_id("su").get_attribute("value")
# print(bd)
# sr = driver.find_element_by_xpath("//*[@id='s-top-left']/a[7]")
# print(sr.text)

# # 实例化 ActionChains
# ac = webdriver.ActionChains(driver)
# # ac = ActionChains(driver)
# # 找到要操作的元素
# ele = driver.find_element_by_partial_link_text("登录")
# # 鼠标悬浮
# ac.move_to_element(ele).perform()
# # 也可以点击下
# # ac.move_to_element(ele).perform()
# sleep(2)
# # ac.click(ele).perform()
driver.find_element_by_css_selector(".red").click()
driver.find_element_by_css_selector("#username").send_keys("13812345678")
driver.find_element_by_css_selector("#password").send_keys("123456")
driver.find_element_by_css_selector("#verify_code").send_keys("8889")
driver.find_element_by_css_selector(".J-login-submit").click()
sleep(2)
msg = driver.find_element_by_css_selector(".layui-layer-content").text
if msg == "验证码错误!":
    print("断言成功")
else:
    print("断言失败")
print(msg)
driver.find_element_by_css_selector(".layui-layer-btn0").click()

sleep(3)
driver.quit()
